<?php

class Article extends Zend_Db_Table{
  protected $_name = 'article';
  protected $_primary = 'id';

  public function getArticles(){
      return $this->fetchAll(null,'posttime desc')->toArray();
  }

  public function getArticleById($artId){
      $db = $this->getAdapter();
      $where = $db->quoteInto('id = ?', $artId);
      $res = $this->fetchRow($where);
      return $res;
  }

  public function getArticlesByCate($cateId){
      $db = $this->getAdapter();
      $where = $db->quoteInto('cateid = ?', $cateId);
      $res = $this->fetchAll($where,'posttime desc');
      return $res;
  }

  public function updateart($id, $set){
      $db = $this->getAdapter();
      $where = $db->quoteInto('id = ?', $id);
      return $this->update($set, $where);
  }

  public function addart($set){
      return $this->insert($set);
  }

  public function deleteart($id){
      $db = $this->getAdapter();
      $where = $db->quoteInto('id = ?', $id);
      return $this->delete($where);
  }
}
